package com.ywj.collection.javaList.MyLinkedList;

import java.util.LinkedList;

public class MyLinkedListDemo1 {
    public static void main(String[] args) {
        LinkedList<String> list = new LinkedList<>();
        list.add("money");
        list.add("study");
        list.add("honor");
        list.add("happy");
        method1(list);
    }

    private static void method1(LinkedList<String> list) {
        list.addFirst("excellence");
        System.out.println("使用addFirst方法后： " + list);
        list.addLast("health");
        System.out.println("使用addLast方法后：  " + list);

        System.out.println("getFirst、getLast：  " + list.getFirst() + ", " + list.getLast());

        String first = list.removeFirst();
        String last = list.removeLast();
        System.out.println("removeFirst、removeLast：  " + first + ", " + last);
        System.out.println(list);
    }
}
